import Vue from 'vue'
import Vuex from 'vuex'
import user from "./modules/user"

Vue.use(Vuex)

const state={
	isShowLoading:false	
}

const actions={	
	showLoading({commit}){  
		commit("showLoading");
	},
	//context对象类store但不是store本身，称"代理"，这在多模块中更加明显
	hideLoading(context){	
		context.commit("hideLoading");
	}
};

const mutations={	
	hideLoading(state){
		state.isShowLoading=false;
	},
	showLoading(state){
		state.isShowLoading=true;
	}
};

const getters={
	getUser(state){
		return state.user
	}
}

export default new Vuex.Store({
	state,
	actions,
	mutations,
	getters,
	modules:{
		user
	}
});